def intersection(nums1, nums2):
    set1 = set(nums1)
    set2 = set(nums2)
    return set_intersection(set1, set2)

def set_intersection(set1, set2):
    if len(set1) > len(set2):
        return set_intersection(set2, set1)
    return [x for x in set1 if x in set2]
n = int(input())
nums1 = [int(x) for x in input().split(" ")]
m = int(input())
nums2 = [int(x) for x in input().split(" ")]
print(intersection(nums1, nums2))